package fr.umlv.m2.jee.portailEtudiant.web;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 19/04/11
 * Time: 20:29
 * To change this template use File | Settings | File Templates.
 */

public class AllowAccessAction extends ActionSupport implements SessionAware {


	private static final long serialVersionUID = 1L;

	private String login;
	private String password;

	private Map<String, Object> session ;

	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public void setSession(Map<String, Object> map){
		this.session=map;
	}

	public Map<String, Object> getSession(){
		return session;
	}

	public String authentifier(){

		System.out.println("dans la methode authentifer........");

		if(this.login!=null && this.password!=null)
			if(this.login.equalsIgnoreCase("struts2") && this.password.equals("struts2")){

				this.session=getSession();
				this.session.put("allowAccess", "true");
				return "success";
			}


		return "input";
	}

	public String deconnecter (){
		System.out.println("dans la méthode deconnecter.......");
		this.session.clear();
		return "success";

	}
}
